﻿using System.Collections.Generic;
using DomainModel;
using Repository.Abstract;

namespace Repository.NHibernate
{
    public class SubgroupRepository : Repository<Subgroup>, ISubgroupRepository
    {
        public Subgroup GetByGroupAndNo(Group group, int no)
        {
            using (Session)
            {
                return Session.QueryOver<Subgroup>().Where(s => s.Group == group && s.GroupNo == no).SingleOrDefault();
            }
        }

        public IEnumerable<Subgroup> GetByGroup(Group group)
        {
            using (Session)
            {
                return Session.QueryOver<Subgroup>().Where(s => s.Group == group).List<Subgroup>();
            }
        }
    }
}